#include<iostream>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int s[11][N];
int n, k;
int arr[N];
int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < n; i++) {
		LL t = arr[i] % k;
		for (int j = 0; j < 11; j++) {
			s[j][t]++;
			t = t * 10 % k;
		}
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		LL t = arr[i] % k;
		int len = to_string(arr[i]).size();
		ans += s[len][(k - t) % k];
		LL r = t;
		while (len--) {
			r = r * 10 % k;
		}
		if (r == (k - t) % k) {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}